﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_SMS_GetNewMsgCount]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_SMS_GetNewMsgCount];
GO
CREATE PROCEDURE [dbo].[sproc_SMS_GetNewMsgCount]
@username nvarchar(30)
/*

===================================================
功能:    得到某用户最新消息数
参数:
    @username         ;    用户名
===================================================

*/
AS
    SELECT COUNT(*) 
        FROM 
            UDS_SMS_Msg,UDS_SMS_Receiver 
        WHERE     
            UDS_SMS_Msg.ID=UDS_SMS_Receiver.MsgID and UDS_SMS_Receiver.Receiver=@Username and UDS_SMS_Receiver.isread=0 and UDS_SMS_Msg.type=1